package com.hejing.反射的应用;

import org.junit.Test;

import java.lang.reflect.Method;

/**
 * ClassName: MethodTest
 * Package: com.hejing.反射的应用
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-06-04 19:15
 * @Version: 1.0
 */
public class MethodTest {
    @Test
    public void test01(){

        Class clazz = Person.class;
        // getMethods(): 获取到运行时类本身及其所有的父类中声明为public权限的方法
        Method[] methods = clazz.getMethods();
        for(Method m: methods) {
            System.out.println(m);
        }

        System.out.println("***********************************************************************************************");

        // getDeclaredMethods(): 获取当前运行时类中声明的所有方法
        Method[] declaredMethods = clazz.getDeclaredMethods();
        for(Method m: declaredMethods) {
            System.out.println(m);
        }
    }
}























